<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    template="/layout/template.xhtml">

<ui:define name="body">

    <rich:panel>
        <f:facet name="header">Categoria</f:facet>


        <s:decorate id="nome" template="/layout/display.xhtml">
            <ui:define name="label">Nome</ui:define>
            <h:outputText value="#{categoriaHome.instance.nome}"/>
        </s:decorate>
        
        
        <s:decorate id="descricao" template="/layout/display.xhtml">
            <ui:define name="label">Descrição</ui:define>
            <h:outputText value="#{categoriaHome.instance.descricao}"/>
        </s:decorate>

        <div style="clear:both"/>

    </rich:panel>

    <div class="actionButtons">

        <s:button view="/resources/CategoriaEdit.xhtml"
                    id="edit"
                 value="Editar"
                 rendered="#{s:hasRole('Subgrupo') or permissao.minhaCategoria}"/>

        <s:button view="/resources/#{empty categoriaFrom ? 'CategoriaList' : categoriaFrom}.xhtml"
                    id="done"
                 value="Concluído"/>

    </div>

    <rich:tabPanel switchType="ajax">

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/manytoone.gif" style="vertical-align: middle; padding-right: 4px;"/>Usuário</h:panelGroup>
        </f:facet>
    <div class="association" id="usuarioParent">

        <h:outputText value="Não existe Usuário associado a esta Categoria."
                   rendered="#{categoriaHome.instance.usuario == null}"/>

        <rich:dataTable var="_usuario"
                   value="#{categoriaHome.instance.usuario}"
                rendered="#{categoriaHome.instance.usuario != null}"
              rowClasses="odd,even"
                      id="usuarioTable">
            <h:column>
                <f:facet name="header">Nome</f:facet>
                <h:outputText value="#{_usuario.nome}"/>
            </h:column>
            <h:column>
                <f:facet name="header">E-mail</f:facet>
                <h:outputText value="#{_usuario.email}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Data de Cadastro</f:facet>
                <h:outputText value="#{_usuario.dataCadastro.time}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Status</f:facet>
                <h:outputText value="#{_usuario.status}"/>
            </h:column>
            <rich:column styleClass="action" style="text-align: center;">
                <f:facet name="header">Opções</f:facet>
                <s:link id="viewusuario"
                     value="Ver"
                      view="/resources/Usuario.xhtml">
                    <f:param name="usuarioId"
                           value="#{_usuario.id}"/>
                </s:link>
            </rich:column>
        </rich:dataTable>

    </div>
    </rich:tab>
    
    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/manytoone.gif" style="vertical-align: middle; padding-right: 4px;"/>Questionário</h:panelGroup>
        </f:facet>
	    <div class="association" id="usuarioParent">
	    	<h:outputText value="Não existe Questionário associado a esta Categoria."
                   rendered="#{categoriaHome.questionario.size == 0}"/>
	    	
	    	<h:form id="formQuestionario">
		    	<rich:dataTable var="_questionario"
		                   value="#{categoriaHome.questionario}"
		                rendered="#{categoriaHome.questionario.size > 0}"
		              rowClasses="odd,even"
		                      id="questionarioTable"
		                     rows="20">
		    	
		    		<h:column>
		                <f:facet name="header">Nome</f:facet>
		                <h:outputText value="#{_questionario.nome}"/>
	            	</h:column>
	            	<h:column>
		                <f:facet name="header">Nível</f:facet>
		                <h:outputText value="#{_questionario.nivel}"/>
	            	</h:column>
	            	<h:column>
		                <f:facet name="header">Cliques</f:facet>
		                <h:outputText value="#{_questionario.cliques}"/>
	            	</h:column>
	            	<h:column>
		                <f:facet name="header">Questões</f:facet>
		                <h:outputText value="#{_questionario.questao.size}"/>
	            	</h:column>
	            	<h:column>
		                <f:facet name="header">Data de Cadastro</f:facet>
		                <h:outputText value="#{_questionario.dataCadastro.time}"/>
	            	</h:column>
	            	<rich:column styleClass="action" style="text-align: center;">
		                <f:facet name="header">Opções</f:facet>
		                <s:link id="viewquestionario"
		                     value="Ver"
		                      view="/resources/Questionario.xhtml">
		                    <f:param name="questionarioId"
		                           value="#{_questionario.id}"/>
		                </s:link>
		            </rich:column>
		    	</rich:dataTable>
		    	
		    	<br clear="left"/>
		    	
		    	<rich:datascroller id="dataScrollerQuestionarioTable" for="questionarioTable" renderIfSinglePage="false"/>
		    </h:form>
	    </div>
	    
	    <div class="actionButtons">
        <s:button
               value="Cadastrar Questionário"
                view="/resources/QuestionarioEdit.xhtml"
            rendered="#{s:hasRole('Subgrupo') or usuario.id eq categoriaHome.instance.usuario.id}">
            <f:param name="categoriaId"
                    value="#{categoriaHome.instance.id}"/>
            <f:param name="pessoaId"
            		value="#{categoriaHome.instance.usuario.id}"/>
            <f:param name="questionarioFrom" value="Categoria"/>
        </s:button>
    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
